using System;
using System.Collections;
using SecuBat.Common;

namespace SecuBat.Threading
{
	/// <summary>
	/// Summary description for SynchronizedHashtable.
	/// </summary>
	public class SynchronizedHashtable : SharedData
	{
		Hashtable _ht;

		public SynchronizedHashtable()
		{
			_ht = new Hashtable();
		}

		public void Add(object key, object value)
		{
			WriteLock();
			_ht.Add(key, value);
			WriteRelease();
		}

		public void Remove(object key)
		{
			WriteLock();
			_ht.Remove(key);
			WriteRelease();
		}

		public bool Contains(object key)
		{
			bool contains;
			ReadLock();
			contains = _ht.Contains(key);
			ReadRelease();
			return contains;
		}

		public int Count
		{
			get
			{
				int count;
				ReadLock();
				count = _ht.Count;
				ReadRelease();
				return count;
			}
		}

	}
}
